<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<script>
    if (window.testRunner) {
        testRunner.dumpAsText();
        testRunner.waitUntilDone();
    }

    var body = document.getElementsByTagName('body')[0];
    var newBody = document.createElement("body");
    body.parentNode.replaceChild(newBody, body);

    function msg(text)
    {
        var n = document.createElement("p");
        n.appendChild(document.createTextNode(text));
        document.body.appendChild(n);
    }

    function verify()
    {
        msg("Test for bug 30049: Manipulating DOM from a script while parsing XHTML can cause a crash.");
        msg("Should say PASS:");
        // Even though a subtree is removed, parsing continues.
        msg(body.getElementsByTagName("foo").length == 1 ? "PASS" : "FAIL");
        if (window.testRunner)
            testRunner.notifyDone();
    }

    setTimeout(verify, 100);
</script>
<script>
    alert("FAIL"); // Firefox compatibility.
</script>
<foo/>
</body>
</html>
